package logic

import (
	"context"
	"new-rent/model/mysql"

	"new-rent/newrentrpc/internal/svc"
	"new-rent/newrentrpc/newrentrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseShowLogic {
	return &HouseShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 房屋详情
func (l *HouseShowLogic) HouseShow(in *newrentrpc.HouseShowRequest) (*newrentrpc.HouseShowResponse, error) {
	// todo: add your logic here and delete this line

	var house mysql.House

	err := house.HouseShow(mysql.DB, in.HouseId)
	if err != nil {
		return nil, err
	}

	return &newrentrpc.HouseShowResponse{
		HouseId: int64(house.ID),
		Name:    house.Name,
		Address: house.Address,
	}, nil
}
